package com.mmcro.oauth.service;

import com.mmcro.oauth.entity.SysAuthority;
import com.mmcro.oauth.entity.SysUser;
import com.mmcro.oauth.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @create: 朱志广
 **/
@Service
public class SysUserService {

    @Autowired
    UserMapper userMapper;


    /**
     *  根据用户名查询用户
     * @param username
     * @return cn.poile.ucs.auth.entity.SysUser
     */
    public SysUser selectByUsername(String username) {
        return userMapper.findUserByName(username);
        //return new SysUser("1","yaohw",new BCryptPasswordEncoder().encode("123456"),"测试字段，根据用户名查询");
    }

    /**
     * 根据手机号查询用户
     * @param mobile
     * @return cn.poile.ucs.auth.entity.SysUser
     */
    public SysUser selectByMobile(String mobile) {
        return userMapper.findUserByMobile(mobile);
       // return new SysUser("2","13683679291",new BCryptPasswordEncoder().encode("123456"),"测试字段，根据手机号查询");
    }

    public List<SysAuthority> getAuthByUserId(int userId) {
        return userMapper.getAtuoritiesByUserId(userId);
        // return new SysUser("2","13683679291",new BCryptPasswordEncoder().encode("123456"),"测试字段，根据手机号查询");
    }

}
